Skip to content

feat: add perf support in walltime#73

Merged
not-matthias merged 7 commits intomainfrom
cod-674-collect-profiles-while-benchmarks-are-running
May 7, 2025
Merged

feat: add perf support in walltime#73
not-matthias merged 7 commits intomainfrom
cod-674-collect-profiles-while-benchmarks-are-running

Conversation

@not-matthias
Copy link
Member

@not-matthias not-matthias commented Mar 25, 2025

TODOs:

Debug logs of successful run:

►►► Running the benchmarks
[DEBUG::codspeed::run::runner::helpers::setup] Running command: sudo sysctl -w kernel.kptr_restrict=0
[DEBUG::codspeed::run::runner::helpers::setup] Running command: sudo sysctl -w kernel.perf_event_paranoid=1
[DEBUG::codspeed::run::runner::wall_time::executor] cmd: ARCH="x86_64" CODSPEED_ENV="runner" CODSPEED_PROFILE_FOLDER="/tmp/profile.riowzUmLRF.out" CODSPEED_RUNNER_MODE="walltime" PYTHONHASHSEED="0" "sh" "-c" "perf record --data --freq=1000 --switch-output --control=fifo:/tmp/codspeed_perf.ctl.fifo,/tmp/codspeed_perf.ack.fifo --delay=-1 -g --output=/tmp/.tmpeI44Iq/perf.datao1Dpk6 -- cargo-codspeed run"
[DEBUG::codspeed::run::runner::wall_time::executor] Perf PID: 527912
Events disabled
[cargo-codspeed] Measurement mode: Walltime

Collected 1 benchmark suite(s) to run
Running graph-analysis my_bench
Timer precision: 13 ns
my_bench        fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ fibonacci                  │               │               │               │         │
Events enabled
[ perf record: dump data: Woken up 1 times ]
[ perf record: Dump /tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120419 ]
Events disabled
│  ╰─ 32        4.563 ms      │ 7.109 ms      │ 4.881 ms      │ 5.07 ms       │ 100     │ 100
╰─ other_bench                │               │               │               │         │
Events enabled
[ perf record: dump data: Woken up 2 times ]
[ perf record: Dump /tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120472 ]
Events disabled
   ╰─ 50        50.06 ms      │ 50.31 ms      │ 50.1 ms       │ 50.12 ms      │ 100     │ 100

Done running   ⠉ Running the benchmarks...                                                                                                                                   my_bench
Finished running 1 benchmark suite(s)
[ perf record: Woken up 2 times to write data ]
[ perf record: Dump /tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120974 ]
[ perf record: Captured and wrote 0.034 MB /tmp/.tmpeI44Iq/perf.datao1Dpk6.<timestamp> ]
  ⠉ Running the benchmarks...                                                                                                                                                [src/run/runner/wall_time/executor.rs:117:9] &perf_files = [
    "/tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120419",
    "/tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120472",
    "/tmp/.tmpeI44Iq/perf.datao1Dpk6.2025032512120974",
]

Copy link
Member

@art049 art049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first quick review, I'll try to review more thouroughly

Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job overall ! Some minor details

Copy link
Member

@art049 art049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good overall :)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/run/runner/wall_time/perf/fifo.rs:168

  • Consider including the actual pid value in the error message to provide clearer context when the process lookup fails.
let bench_proc = procfs::process::Process::new(pid as _).expect("Failed to find benchmark process");

@not-matthias not-matthias requested a review from art049 April 8, 2025 15:54
Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great piece of work! Some overall small changes, next should be the last round of review!

@GuillaumeLagrange GuillaumeLagrange deleted the cod-674-collect-profiles-while-benchmarks-are-running branch April 11, 2025 06:19
@GuillaumeLagrange GuillaumeLagrange restored the cod-674-collect-profiles-while-benchmarks-are-running branch April 11, 2025 06:19
@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch 3 times, most recently from 95c91a1 to 6d4a041 Compare April 22, 2025 09:06
@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch from 6d4a041 to 8fca095 Compare April 25, 2025 09:04
Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor comments appart from the multi-threading stuff we discussed IRL

@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch from 8fca095 to 1b67cd8 Compare April 25, 2025 13:00
@adriencaccia adriencaccia force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch 2 times, most recently from bec9d0a to 26b46ad Compare April 29, 2025 08:03
@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch 3 times, most recently from 94bebd2 to e43a2ff Compare May 1, 2025 12:51
@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch 3 times, most recently from 80d0929 to 73a079c Compare May 7, 2025 07:53
@not-matthias
Copy link
Member Author

@GuillaumeLagrange Only minor changes in this PR: Added conditional dependency of procfs, disabled USE_PERF by default, install perf on setup if not found.

Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, good work!

@not-matthias not-matthias force-pushed the cod-674-collect-profiles-while-benchmarks-are-running branch from 73a079c to 4d6c062 Compare May 7, 2025 08:31
@not-matthias not-matthias merged commit 4d6c062 into main May 7, 2025
9 checks passed
@not-matthias not-matthias deleted the cod-674-collect-profiles-while-benchmarks-are-running branch May 7, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants